<template>
  <el-card style="margin-bottom:20px;">
    <div slot="header" class="clearfix">
      <span style="line-height:29px;">账号信息</span>
      <el-button
        type="primary"
        icon="el-icon-remove"
        size="mini"
        style="float:right;"
        @click="delAccount"
      >
        删除帐号
      </el-button>
    </div>

    <div class="user-profile">
      <div class="box-center">
        <!-- <pan-thumb :image="user.avatar" :height="'100px'" :width="'100px'" :hoverable="false">
          <div>Hello</div>
          {{ user.role }}
        </pan-thumb> -->
        <el-image :src="account.image" class="avatar" />
      </div>
      <div class="box-center">
        <div class="user-name text-center">{{ account.userName }}</div>
        <div class="user-role text-center text-muted">{{ account.role | role }}</div>
      </div>
    </div>
    <!-- <svg-icon icon-class="gender" /> -->
    <div class="user-bio">
      <div class="user-education user-bio-section">
        <div class="user-bio-section-header"><span>账号</span></div>
        <div class="user-bio-section-body">
          <div class="text-muted">{{ account.account }}</div>
        </div>
      </div>
      <div class="user-education user-bio-section">
        <div class="user-bio-section-header"><span>地址</span></div>
        <div class="user-bio-section-body">
          <div class="text-muted">{{ account.province }} {{ account.city }} {{ account.county }}</div>
        </div>
      </div>
      <div class="user-education user-bio-section">
        <div class="user-bio-section-header"><span>详细地址</span></div>
        <div class="user-bio-section-body">
          <div class="text-muted">{{ account.location }}</div>
        </div>
      </div>
      <div class="user-education user-bio-section">
        <div class="user-bio-section-header"><span>邮箱</span></div>
        <div class="user-bio-section-body">
          <div class="text-muted">{{ account.email | isEmpty }}</div>
        </div>
      </div>
      <div class="user-education user-bio-section">
        <div class="user-bio-section-header"><span>联系方式</span></div>
        <div class="user-bio-section-body">
          <div class="text-muted">{{ account.phone | isEmpty }}</div>
        </div>
      </div>
      <div class="user-education user-bio-section">
        <div class="user-bio-section-header"><span>性别</span></div>
        <div class="user-bio-section-body">
          <div class="text-muted">{{ account.sex }}</div>
        </div>
      </div>
      <div class="user-education user-bio-section">
        <div class="user-bio-section-header"><span>年龄</span></div>
        <div class="user-bio-section-body">
          <div class="text-muted">{{ account.age }}</div>
        </div>
      </div>

      <!-- <div class="user-skills user-bio-section">
        <div class="user-bio-section-header"><svg-icon icon-class="skill" /><span>Skills</span></div>
        <div class="user-bio-section-body">
          <div class="progress-item">
            <span>Vue</span>
            <el-progress :percentage="70" />
          </div>
          <div class="progress-item">
            <span>JavaScript</span>
            <el-progress :percentage="18" />
          </div>
          <div class="progress-item">
            <span>Css</span>
            <el-progress :percentage="12" />
          </div>
          <div class="progress-item">
            <span>ESLint</span>
            <el-progress :percentage="100" status="success" />
          </div>
        </div>
      </div> -->
    </div>
  </el-card>
</template>

<script>
// import { mapGetters } from 'vuex'
// import { deleteAccounts } from '@/api/admin'
import { delAccount } from '@/api/account'

export default {
  filters: {
    role(index) {
      const roles = ['超管账号', '基地管理帐号', '普通用户账号', '保留', '企业管理帐号']
      return roles[Number.parseInt(index)]
    }
  },
  props: {
    account: {
      type: Object,
      required: true
    }
  },
  // computed: {
  //   ...mapGetters([
  //     'imgSrc',
  //     'avatar'
  //   ])
  // },
  methods: {
    async delAccount() {
      this.$confirm('确定删除此帐号吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async() => {
        const account = this.account.account
        const res = await delAccount({ account })
        if (res) {
          this.$message({
            type: 'success',
            message: '删除成功！'
          })
          this.$router.push({
            path: '/user'
          })
        }
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.box-center {
  margin: 0 auto;
  display: table;

  .avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    box-shadow: 0 5px 10px 0 rgb(215,215,215);
  }
}

.text-muted {
  color: #777;
}

.user-profile {
  .user-name {
    font-weight: bold;
  }

  .box-center {
    padding-top: 10px;
  }

  .user-role {
    padding-top: 10px;
    font-weight: 400;
    font-size: 14px;
  }

  .box-social {
    padding-top: 30px;

    .el-table {
      border-top: 1px solid #dfe6ec;
    }
  }

  .user-follow {
    padding-top: 20px;
  }
}

.user-bio {
  margin-top: 20px;
  color: #606266;

  span {
    padding-left: 4px;
  }

  .user-bio-section {
    font-size: 14px;
    padding: 15px 0;

    .user-bio-section-header {
      border-bottom: 1px solid #dfe6ec;
      padding-bottom: 10px;
      margin-bottom: 10px;
      font-weight: bold;
    }
  }
}
</style>
